package com.isdepci.project.carbon.controller;

import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.framework.web.page.TableDataInfo;
import com.isdepci.project.carbon.domain.BLiquidFuel;
import com.isdepci.project.carbon.domain.param.WeatherDataExcel;
import com.isdepci.project.carbon.service.IBLiquidFuelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 液体燃料燃烧碳排放Controller
 *
 * @author isdepci
 * @date 2025-03-29
 */
@RestController
@RequestMapping("/liquid/fuel")
public class BLiquidFuelController extends BaseController
{
    @Autowired
    private IBLiquidFuelService bLiquidFuelService;


    /**
     * 液体燃料计算
     */
    @GetMapping("/calLiquidFuel")
    public AjaxResult calLiquidFuel(@RequestParam Long projectId) {
        return bLiquidFuelService.calLiquidFuel(projectId);
    }



    /**
     * 查询液体燃料燃烧碳排放列表
     */
    //  @PreAuthorize("@ss.hasPermi('liquid:fuel:list')")
    @GetMapping("/list")
    public TableDataInfo list(BLiquidFuel bLiquidFuel)
    {
        startPage();
        List<BLiquidFuel> list = bLiquidFuelService.selectBLiquidFuelList(bLiquidFuel);
        return getDataTable(list);
    }

    /**
     * 导出液体燃料燃烧碳排放列表
     */
    //  @PreAuthorize("@ss.hasPermi('liquid:fuel:export')")
    @Log(title = "液体燃料燃烧碳排放", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BLiquidFuel bLiquidFuel)
    {
        List<BLiquidFuel> list = bLiquidFuelService.selectBLiquidFuelList(bLiquidFuel);
        ExcelUtil<BLiquidFuel> util = new ExcelUtil<BLiquidFuel>(BLiquidFuel.class);
        return util.exportExcel(list, "fuel");
    }

    /**
     * 上传保存数据
     * @param excel
     * @return
     */
    @PostMapping("/changeData")
    public AjaxResult changeDataByProjectId(@RequestBody WeatherDataExcel excel) {
        return bLiquidFuelService.changeDataByProjectId(excel);
    }


    /**
     * 获取液体燃料燃烧碳排放详细信息
     */
    //  @PreAuthorize("@ss.hasPermi('liquid:fuel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bLiquidFuelService.selectBLiquidFuelById(id));
    }

    /**
     * 新增液体燃料燃烧碳排放
     */
    //  @PreAuthorize("@ss.hasPermi('liquid:fuel:add')")
    @Log(title = "液体燃料燃烧碳排放", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BLiquidFuel bLiquidFuel)
    {
        return toAjax(bLiquidFuelService.insertBLiquidFuel(bLiquidFuel));
    }

    /**
     * 修改液体燃料燃烧碳排放
     */
    //  @PreAuthorize("@ss.hasPermi('liquid:fuel:edit')")
    @Log(title = "液体燃料燃烧碳排放", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BLiquidFuel bLiquidFuel)
    {
        return toAjax(bLiquidFuelService.updateBLiquidFuel(bLiquidFuel));
    }

    /**
     * 删除液体燃料燃烧碳排放
     */
    //  @PreAuthorize("@ss.hasPermi('liquid:fuel:remove')")
    @Log(title = "液体燃料燃烧碳排放", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bLiquidFuelService.deleteBLiquidFuelByIds(ids));
    }
}
